﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Acms.Bll;

/// <summary>
/// Summary description for BaseMenuPage
/// </summary>
public abstract class BaseMenuPage : BasePage
{
    public BaseMenuPage()
    {
    }

    protected override void OnLoad(EventArgs e)
    {
        if (Request.QueryString["Id"] != null)
        {
            try
            {
                MenuId = int.Parse(Request.QueryString["Id"]);
            }
            catch
            {
            }
        }
        base.OnLoad(e);
    }

    public abstract Role.Roles[] EditRoles { get; }

    protected int MenuId { get; private set; }
    private Acms.Bll.Menu _CurrentMenu;
    protected Acms.Bll.Menu CurrentMenu
    {
        get 
        {
            if (MenuId > 0 && _CurrentMenu == null)
            {
                _CurrentMenu = Acms.Bll.Menu.GetById(MenuId, AcmsContext.SiteId);
            }

            return _CurrentMenu; 
        }
    }

    public override void GetBreadCrumbs(BaseMasterPage.BreadCrumbCollection breadcrumbs)
    {
        breadcrumbs.Add("Settings", null);
        breadcrumbs.Add("Menus", "~/Menus");
        if (CurrentMenu != null)
        {
            breadcrumbs.Add(CurrentMenu.Name, null);
        }
    }
}
